﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ListView.aspx.cs" Inherits="ListView" %>
<%@ Register assembly="GenericDataLayer" namespace="DataLayer.Generic" tagprefix="DataLayer" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <DataLayer:GenericObjectDataSource  ID="ProductDataSource" runat="server"
            DataObjectTypeName="DataLayer.Product" 
            TypeName="DataLayer.ProductStaticRepository" 
            EnablePaging="true"
           />
        
        <DataLayer:GenericObjectDataSource ID="CategoryDataSource" runat="server" 
            DataObjectTypeName="DataLayer.Category" 
            TypeName="DataLayer.CategoryStaticRepository"
            />
            
        <asp:DataPager ID="ProductDataPager" runat="server" PagedControlID="ProductListView" PageSize="5"/>
            
        <asp:ListView ID="ProductListView" runat="server" DataKeyNames="ProductID" DataSourceID="ProductDataSource" >
            <LayoutTemplate>
                <asp:PlaceHolder ID="itemPlaceHolder" runat="server"/>            
            </LayoutTemplate>
            <ItemTemplate>
                <div>
                    <p>
                        <asp:Label ID="ProductNameLabel" runat="server" AssociatedControlID="ProductNameLiteral" />
                        <asp:Literal ID="ProductNameLiteral" runat="server" Text='<%# Eval("ProductName") %>' />
                    </p>
                    <p>
                        <asp:Button ID="EditButton" runat="server" Text="Edit" CommandName="Edit" />
                        <asp:Button ID="DeleteButton" runat="server" Text="Delete" CommandName="Delete" />
                    </p>
                </div>
            </ItemTemplate>
            <InsertItemTemplate>
                <div>
                    <p>
                        <asp:Label ID="ProductNameLabel" runat="server" AssociatedControlID="ProductNameLiteral" />
                        <asp:Literal ID="ProductNameLiteral" runat="server" Text='<%# Bind("ProductName") %>' />
                    </p>            
                    <p>
                        <asp:Button ID="InsertButton" runat="server" Text="Save" CommandName="Insert" />
                    </p>
                </div>
            </InsertItemTemplate>
            <EditItemTemplate>
                <div>
                    <p>
                        <asp:Label ID="ProductNameLabel" runat="server" AssociatedControlID="ProductNameTextBox" />
                        <asp:TextBox ID="ProductNameTextBox" runat="server" Text='<%# Bind("ProductName") %>' />
                    </p>
                    <p>
                        <asp:Button ID="UpdateButton" runat="server" Text="Update" CommandName="Update" />
                        <asp:Button ID="CancelButton" runat="server" Text="Cancel" CommandName="Cancel" />
                    </p>                
                </div>        
            </EditItemTemplate>
        </asp:ListView>
    </div>
    </form>
</body>
</html>
